package pl.taskman.view.components;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.beans.PropertyChangeEvent;

import pl.taskman.core.AbstractViewPanel;
import pl.taskman.helper.ColorHelper;

/*
 * Test class for creating a custom content panel
 * 
 * @author NiTh [nith4r0@gmail.com]
 */
public class CustomPanel extends AbstractViewPanel
{
	/**
	 * Generated serial ID
	 */
	private static final long	serialVersionUID	= 7541638347383367508L;
	private Color				bgColor				= null;

	public CustomPanel(Color bgColor)
	{
		super();
		this.bgColor = bgColor;
	}

	public static enum PanelType
	{
		MAIN_MENU, LOGIN_MENU
	};

	@Override
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);

		fillScreen(g, bgColor);
	}

	/**
	 * Fills the panel surface with specified color
	 * 
	 * @param g Graphics context
	 * @param color Color to fill the surface with
	 */
	private void fillScreen(Graphics g, Color color)
	{
		Graphics2D g2 = (Graphics2D) g;
		GradientPaint gradient = null;

		gradient = new GradientPaint((getWidth() / 2), 0, color,
						(getWidth() / 2), (int) (getHeight() / 0.8),
						ColorHelper.darken(color, 50), false);

		g2.setPaint(gradient);
		g2.fillRect(0, 0, getWidth(), getHeight());
	}

	@Override
	public void modelPropertyChange(PropertyChangeEvent evt)
	{
		// TODO Auto-generated method stub	
	}
}
